/**
 * <pre>项目名称:LogApp-SpringBoot-Demo 
 * 文件名称:send.java 
 * 包名:com.jk.mq 
 * 创建日期:2017年12月20日下午8:30:30 
 * Copyright (c) 2017, 896670039@qq.com All Rights Reserved.</pre> 
 */
package com.jk.util;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class Send  {

    private RabbitTemplate rabbitTemplate;

    /**
     * 构造方法注入
     *
     */
    @Autowired
    public Send(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public void sendMsg(Object content) {

        CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend("spring-boot-exchange", "spring-boot-routingKey", content, correlationId);

								        /*
								          convertAndSend(String exchange, String routingKey, final Object object, CorrelationData correlationData)
								          exchange:交换机名称                           routingKey:路由关键字       object:发送的消息内容            correlationData:消息ID
								         */
    }
   public void sendMsgAuthIdCard(Object content) {

        CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend("spring-boot-exchange-idCard", "spring-boot-routingKey-idcard", content, correlationId);

								        /*
								          convertAndSend(String exchange, String routingKey, final Object object, CorrelationData correlationData)
								          exchange:交换机名称                           routingKey:路由关键字       object:发送的消息内容            correlationData:消息ID
								         */
    }

    public void sendMsgAuthOrgInfo(Object content) {

        CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend("spring-boot-exchange-orgInfo", "spring-boot-routingKey-orgInfo", content, correlationId);

								        /*
								          convertAndSend(String exchange, String routingKey, final Object object, CorrelationData correlationData)
								          exchange:交换机名称                           routingKey:路由关键字       object:发送的消息内容            correlationData:消息ID
								         */
    }

    public void sendMsgAuthRep(Object content) {

        CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend("spring-boot-exchange-rep", "spring-boot-routingKey-rep", content, correlationId);

								        /*
								          convertAndSend(String exchange, String routingKey, final Object object, CorrelationData correlationData)
								          exchange:交换机名称                           routingKey:路由关键字       object:发送的消息内容            correlationData:消息ID
								         */
    }

}  